package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.CheckInConfigDto;
import com.zzyl.dto.CheckInDto;
import com.zzyl.dto.ContractDto;
import com.zzyl.service.CheckInConfigService;
import com.zzyl.service.CheckInService;
import com.zzyl.service.ContractService;
import com.zzyl.vo.retreat.TasVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkIn")
@Api(tags = "入住")
public class CheckInController {

    @Autowired
    private CheckInService checkInService;

    @PostMapping("/create")
    @ApiOperation("申请入住")
    public ResponseResult createCheckIn(@RequestBody CheckInDto checkInDto) {
        return checkInService.createCheckIn(checkInDto);
    }

    @GetMapping
    @ApiOperation("查询入住表单")
    public ResponseResult<TasVo> getCheckIn(String assigneeId, String code, Integer flowStatus, String taskId) {
        return checkInService.getCheckIn(assigneeId, code, flowStatus, taskId);
    }

    @PostMapping("/review")
    public ResponseResult review(@RequestBody CheckInDto checkInDto) {
        return checkInService.review(checkInDto);
    }

    @PutMapping("/submit")
    public ResponseResult submitCheckIn(Long id, String taskId, String message) {
        return checkInService.submitCheckIn(id, taskId, message);
    }

    @PutMapping("/reject")
    public ResponseResult auditReject(Long id, String taskId, String message) {
        return checkInService.auditReject(id, taskId, message);
    }

    @PutMapping
    public ResponseResult disapprove(Long id, String taskId, String message) {
        return checkInService.disapprove(id, taskId, message);
    }

    @PutMapping("/revocation")
    public ResponseResult revocation(Long id,String flowStatus,String taskId) {
        return checkInService.revocation(id,flowStatus,taskId);
    }

    @PutMapping("/cancel")
    public ResponseResult cancel(Long id,String taskId){
        return checkInService.cancel(id,taskId);
    }

    @Autowired
    private CheckInConfigService checkInConfigService;

    @PostMapping
    public ResponseResult checkIn(@RequestBody CheckInConfigDto checkInConfigDto){
        return checkInConfigService.checkIn(checkInConfigDto);
    }

    @Autowired
    private ContractService contractService;

    @PostMapping("/sign")
    public ResponseResult sign(@RequestBody ContractDto contractDto){
        return contractService.sign(contractDto);
    }

}
